/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.firstpart.location.mapper.OrderStoreMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.firstpart.location.mapper;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.*;
import com.yonyou.iuap.yms.param.ResultSetProcessor;
import com.yonyou.iuap.yms.processor.*;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.location.entity.OrderStoreEntity;

import java.sql.Types;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class OrderStoreMapperImpl {

    @Autowired
    private IYmsJdbcApi ymsJdbcApi;

    public OrderStoreEntity selectByMainId(String mainid) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from `dxq_orderstore` where `mainid`=?;\n";
        parameter.addParam(mainid);

        ResultSetProcessor processor = new AutoBeanProcessor(new OrderStoreEntity());
        return (OrderStoreEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public OrderStoreEntity selectByPrimaryKey(Integer id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxq_orderstore where `id` = ?\n";
        parameter.addParamWithType(id, Types.INTEGER);

        ResultSetProcessor processor = new AutoBeanProcessor(new OrderStoreEntity());
        return (OrderStoreEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int insertSelective(OrderStoreEntity record) {
        
        return 0;
    }


    public int updateByPrimaryKeySelective(OrderStoreEntity record) {
        
        return 0;
    }


    public int updateByPrimaryKey(OrderStoreEntity record) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "update dxq_orderstore set `datatype` = ?, `datastatus` = ?, `dr` = ?, `transtype` = ?, `mainid` = ?, `code` = ?, `type` = ?, `status` = ?, `shopid` = ?, `inventoryowner` = ?, `receiveid` = ?, `tplid` = ?, `warehouseid` = ?, `operateuserid` = ?, `operatetime` = ?, `operatetype` = ?, `operatetypename` = ?, `sourceid` = ?, `sourcecode` = ?, `firstsourceid` = ?, `firstsourcecode` = ? where `id` = ?\n";
        parameter.addParamWithType(record.getDatatype(), Types.INTEGER);
		parameter.addParamWithType(record.getDatastatus(), Types.INTEGER);
		parameter.addParamWithType(record.getDr(), Types.SMALLINT);
		parameter.addParamWithType(record.getTranstype(), Types.VARCHAR);
		parameter.addParamWithType(record.getMainid(), Types.VARCHAR);
		parameter.addParamWithType(record.getCode(), Types.VARCHAR);
		parameter.addParamWithType(record.getType(), Types.INTEGER);
		parameter.addParamWithType(record.getStatus(), Types.INTEGER);
		parameter.addParamWithType(record.getShopid(), Types.VARCHAR);
		parameter.addParamWithType(record.getInventoryowner(), Types.VARCHAR);
		parameter.addParamWithType(record.getReceiveid(), Types.VARCHAR);
		parameter.addParamWithType(record.getTplid(), Types.VARCHAR);
		parameter.addParamWithType(record.getWarehouseid(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperateuserid(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperatetime(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperatetype(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperatetypename(), Types.VARCHAR);
		parameter.addParamWithType(record.getSourceid(), Types.VARCHAR);
		parameter.addParamWithType(record.getSourcecode(), Types.VARCHAR);
		parameter.addParamWithType(record.getFirstsourceid(), Types.VARCHAR);
		parameter.addParamWithType(record.getFirstsourcecode(), Types.VARCHAR);
		parameter.addParamWithType(record.getId(), Types.INTEGER);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public int insert(OrderStoreEntity record) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "insert into dxq_orderstore (`datatype`, `datastatus`,  `transtype`, `mainid`,  `code`, `type`, `status`,  `shopid`, `inventoryowner`,  `receiveid`, `tplid`,  `dr`, `warehouseid`,  `operateuserid`, `operatetime`,  `operatetype`, `operatetypename`,  `sourceid`, `sourcecode`,  `firstsourceid`, `firstsourcecode`) values (?, ?,  ?, ?,  ?, ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?,  ?, ?)\n";
        parameter.addParamWithType(record.getDatatype(), Types.INTEGER);
		parameter.addParamWithType(record.getDatastatus(), Types.INTEGER);
		parameter.addParamWithType(record.getTranstype(), Types.VARCHAR);
		parameter.addParamWithType(record.getMainid(), Types.VARCHAR);
		parameter.addParamWithType(record.getCode(), Types.VARCHAR);
		parameter.addParamWithType(record.getType(), Types.INTEGER);
		parameter.addParamWithType(record.getStatus(), Types.INTEGER);
		parameter.addParamWithType(record.getShopid(), Types.VARCHAR);
		parameter.addParamWithType(record.getInventoryowner(), Types.VARCHAR);
		parameter.addParamWithType(record.getReceiveid(), Types.VARCHAR);
		parameter.addParamWithType(record.getTplid(), Types.VARCHAR);
		parameter.addParamWithType(record.getDr(), Types.SMALLINT);
		parameter.addParamWithType(record.getWarehouseid(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperateuserid(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperatetime(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperatetype(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperatetypename(), Types.VARCHAR);
		parameter.addParamWithType(record.getSourceid(), Types.VARCHAR);
		parameter.addParamWithType(record.getSourcecode(), Types.VARCHAR);
		parameter.addParamWithType(record.getFirstsourceid(), Types.VARCHAR);
		parameter.addParamWithType(record.getFirstsourcecode(), Types.VARCHAR);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public int selectCount(String mainid) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from `dxq_orderstore` where `dr`=0 and `mainid`=?;\n";
        parameter.addParam(mainid);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int deleteByPrimaryKey(Integer id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "delete from dxq_orderstore where `id` = ?\n";
        parameter.addParamWithType(id, Types.INTEGER);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public int editEntityFlag(String mainid) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "update `dxq_orderstore` set `dr`=1 where `dr`=0 and `mainid`=?;\n";
        parameter.addParam(mainid);

        
        return ymsJdbcApi.update(sql, parameter);
    }

}
